/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bankowosc;

import bankowosc.dane.Polecenie_przelewu;
import bankowosc.dane.Wniosek;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Cyga
 */
public class TablicaWnioski extends AbstractTableModel {
  Wniosek k = new  Wniosek();
  int id_klienta;
    public Wniosek getK() {
        return k;
    }

    public int getId_klienta() {
        return id_klienta;
    }

    public void setId_klienta(int id_klienta) {
        this.id_klienta = id_klienta;
    }

    public void setK(Wniosek k) {
        this.k = k;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public ArrayList<Wniosek> getWnioski() {
        return wnioski;
    }

    public void setWnioski(ArrayList<Wniosek> wnioski) {
        this.wnioski = wnioski;
    }

 String id ;
    private ArrayList<Wniosek> wnioski = null;
    private final static Object[] columnNames = {"ID", "status","data złożenia","Typ"};
     private static final Class<?>[] COLUMN_TYPES = new Class<?>[] {Integer.class, String.class, Date.class,String.class };
    private final static int id_IDX = 0;
    private final static int status = 1;
    private final static int typ = 3;
    private final static int data = 2;
   
 
    public TablicaWnioski() {}
     @Override public Class<?> getColumnClass(int columnIndex) {
			return COLUMN_TYPES[columnIndex];
		}
    @Override
    public int getRowCount() {
        if(wnioski==null) return 0;
        return wnioski.size();
    }
 
    @Override
    public int getColumnCount() {
        return columnNames.length;
    }
     
    @Override
    public Object getValueAt(final int rowIndex,final int columnIndex) {
 
        if(wnioski == null) return null;
        
        final Wniosek p = (Wniosek) wnioski.get(rowIndex);
        switch (columnIndex) {
            case id_IDX:
                return p.getId_wniosku();
            case status:
                if(p.getId_rezultat()==1)
                return "Przyjęty";
                else if(p.getId_rezultat()==2)
                return "Odrzucony";
                else if(p.getId_rezultat()==3)
                return "W trakcie";
            case typ:
       
					 if(p.getId_typ()==1)
                return "O kredyt";
                else if(p.getId_typ()==2)
                return "O kartę";
            case data:
                return p.getData();
           
            default:
                return p;
        }
    }
 public void wyczysc(){
 wnioski.clear();
 }
    @Override
    public String getColumnName(int column) {
        return columnNames[column].toString();
    }
 
    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }
     
    public void setModelData(ArrayList<Wniosek> wnioski) {
       this.wnioski =  wnioski;
          
    }
    public Wniosek getKlub(int position) {
        return wnioski.get(position);
    }
   
    

}
